<%@ page import="com.entity.Store" %>
<%@ page import="java.util.List" %>

<%@ page import="com.Imp.StoreMapperImpl" %>
<%@ page import="com.mapper.StoreMapper" %>
<%@ page import="com.mapper.CustomerMapper" %>
<%@ page import="com.Imp.CustomerMapperImpl" %>
<%@ page import="com.entity.Customer" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面布局</title>
    <!-- 新 Bootstrap5 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css">
    <!--  popper.min.js 用于弹窗、提示、下拉菜单 -->
    <script src="https://cdn.staticfile.org/popper.js/2.9.3/umd/popper.min.js"></script>
    <!-- 最新的 Bootstrap5 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.min.js"></script>

    <link rel="stylesheet" type="text/css" href="./css/storeList.css">
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark ">


            <div class="container-fluid">
                <a class="navbar-brand" href="#"><img src="./img/caidan.png" height="35" width="35">&nbsp菜单</a>
                <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                    <%
                        String customerId = (String) session.getAttribute("username");
                        CustomerMapper customerMapper = new CustomerMapperImpl();
                        Customer customer = customerMapper.getCustomerByUserName(customerId);
                    %>
                    <li class="nav-item">
                        <a class="nav-link" href="information_customer.jsp">尊贵的顾客&nbsp<%=customer.getName() %>，您好！  </a>
                    </li>

                    <li class="nav-item">
                        <a class="nav-link" href="login.jsp">退出登录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">关于我们</a>
                    </li>
                </ul>
            </div>
        </nav>
    </div>

    <div class="row">
        <div class="col-md-2 sidebar">
            <div class="sidebar-menu">
                <ul class="custom-list ">
                    <li><a href="main.jsp"><img src="./img/main.png" height="18" width="18">&nbsp主页</a></li>
                    <li class="active" ><a href="storeList.jsp" style="background-color: #55aaff;"><img src="./img/shop.png" height="18" width="18">&nbsp店铺</a></li>
                    <li><a href="cart.jsp"><img src="./img/shoppingTrolley.png" height="18" width="18">&nbsp购物车</a></li>
                    <div id="order">
                        <div class="orderlist">
                            <a class="btn" data-bs-toggle="collapse" href="#collapseOne"><img src="./img/order.png" height="18" width="18">&nbsp我的订单</a>
                        </div>
                        <div id="collapseOne" class="collapseshow collapse" data-bs-parent="#order">
                            <div class="orderlist-body">
                                <a href="waitingOrders.jsp">待配送</a>
                            </div>
                        </div>
                        <div id="collapseOne" class="collapseshow collapse" data-bs-parent="#order">
                            <div class="orderlist-body">
                                <a href="deliveringOrders.jsp">配送中</a>
                            </div>
                        </div>
                        <div id="collapseOne" class="collapseshow collapse" data-bs-parent="#order">
                            <div class="orderlist-body">
                                <a href="deliveredOrders.jsp">已完成</a>
                            </div>
                        </div>
                    </div>

                    <li><a href="information_customer.jsp"><img src="./img/personal.png" height="18" width="18">&nbsp个人信息</a></li>
                    <li></li>
                </ul>
            </div>
        </div>

        <div class="col-md-10 main-content">
            <div class="table-responsive">
                <table class="table table-striped table-bordered">
                    <thead class="table-dark">
                    <tr>
                        <th>店铺编号</th>
                        <th>店铺名</th>
                        <th>店铺评分</th>
                        <th>备注</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <%
                        try {
                            StoreMapper storeMapper = new StoreMapperImpl();
                            List<Store> stores = storeMapper.getAllstores();
                            for (Store store : stores) {
                    %>
                    <tr>
                        <td><%= store.getStoreId() %></td>
                        <td><%= store.getName() %></td>
                        <td><%= store.getEvaluation() %></td>
                        <td><%= store.getRemark() %></td>
                        <td>
                            <a href="menu.jsp?id=<%= store.getStoreId() %>" class="btn btn-primary">查看详情</a>
                        </td>
                    </tr>
                    <%
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            System.out.println("数据库连接失败");
                        }
                    %>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>

</body>
</html>
